package com.xyhua.houseproperty.service;


import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@Service
public class FileService {


    public String getImagePath(MultipartFile avatarFile) {
        File newFile = FileUtil.touch("./avatar/" + System.currentTimeMillis() + "-" + avatarFile.getOriginalFilename());
        try {
            FileUtil.writeBytes(avatarFile.getBytes(), newFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return newFile.getName();
    }
}
